#include <mediator_pattern.h>
#include <iostream>
#include <ctime>
#include <iomanip>

void ChatRoom::showMessage(User *user, string message)
{
    time_t now = time(0);
    tm *ltm = localtime(&now);
    cout << 1900 + ltm->tm_year << "-" << 1 + ltm->tm_mon << "-" << ltm->tm_mday << " " << ltm->tm_hour << ":" << setw(1) << setfill('0') << ltm->tm_min << ":" << ltm->tm_sec << " [ " << user->getName() << " ] : " << message << endl;
}

User::User(string name)
{
    this->name = name;
}

string User::getName()
{
    return this->name;
}

void User::setName(string name)
{
    this->name = name;
}

void User::sendMessage(string message)
{
    ChatRoom::showMessage(this, message);
}
